<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<h1>Spring Boot file upload example</h1>
<span th:if="${msg!=null}" th:utext="${msg}" style="color: red"></span>

<hr style="height:1px;border:none;border-top:1px solid #555555;"/>
<p>文件列表</p>
<table border="1" th:if="${filesName!=null}">
    <tr>
        <td align="center">编号</td>
        <td align="center">文件名</td>
        <td align="center">操作</td>
    </tr>
    <tr th:each="file:${filesName}">
        <td th:text="${fileStat.index+1}"></td>
        <td th:text="${file}"></td>
        <td>
            <a th:href="@{deleteFile+'/'+${file}}">删除</a>
        </td>
    </tr>

</table>

<hr style="height:1px;border:none;border-top:1px solid #555555;"/>
<p>单文件上传</p>
<form th:action="@{/uploadFile}" method="POST" enctype="multipart/form-data">
    文件：<input type="file" name="file"/>
    <input type="submit"/>
</form>

<hr style="height:1px;border:none;border-top:1px solid #555555;"/>

<div th:if="${img!=null}">
    <img th:src="${img}">
    <p>文件下载</p>
    <form th:action="@{/download}" method="post">
        <input type="hidden" th:value="${img}" name="fileName"/>
        <input type="submit" value="下载文件"/>
    </form>
    <br>
</div>
<br>
<div>
    <p>根据文件名下载</p>
    <form th:action="@{/download}" method="post">
        <input type="text" name="fileName"/>
        <input type="submit" value="下载文件"/>
    </form>
</div>

<hr style="height:1px;border:none;border-top:1px solid #555555;"/>
<div>
    <form role="form" method="post" th:action="@{/uploadMultiple}" enctype="multipart/form-data">
        <div class="form-group">
            <label for="exampleInputEmail1">邮箱</label>
            <input type="email" name="email" class="form-control" id="exampleInputEmail1"
                   placeholder="Enter email">
        </div>
        <div class="form-group">
            <label for="exampleInputPassword1">用户名</label>
            <input type="text" name="username" class="form-control" id="exampleInputPassword1"
                   placeholder="Password">
        </div>
        <!--单文件上传-->
        <div class="form-group">
            <label for="exampleInputFile">头像</label>
            <input name="headImg" type="file" id="exampleInputFile">
            <p class="help-block">Example block-level help text here.</p>
        </div>
        <!--多文件上传-->
        <div class="form-group">
            <label for="exampleInputFile">生活照</label>
            <input name="photos" type="file" multiple>
            <p class="help-block">Example block-level help text here.</p>
        </div>
        <div class="checkbox">
            <label>
                <input type="checkbox"> Check me out
            </label>
        </div>
        <button type="submit" class="btn btn-primary">提交</button>
    </form>
</div>

</body>
</html>
